import {
  Message,
  MessageBox,
  Notification,
  Loading
} from 'element-ui'

function addNewStyle(newStyle) {
  var styleElement = document.getElementById('styles_js');

  if (!styleElement) {
    styleElement = document.createElement('style');
    styleElement.type = 'text/css';
    styleElement.id = 'styles_js';
    document.getElementsByTagName('head')[0].appendChild(styleElement);
  }

  styleElement.appendChild(document.createTextNode(newStyle));
}

addNewStyle('.searchButton { width: 40px;border: 0px;height: 27px;background: #598AF9 !important;border-radius: 3px;font-size: 12px;margin-right: 10px;font-family: Microsoft YaHei;font-weight: bold;letter-spacing: 0;color: #FEFBFB;line-height: 10px;letter-spacing: 2px;}');
addNewStyle('.resetButton {border: 1px solid #2985F7;border-radius: 2px;width: 40px;height: 27px;background: #fff;font-size: 12px;font-family: Microsoft YaHei;line-height: 9px;font-weight: bold;letter-spacing: 0;color: #598af9;letter-spacing: 2px;}');

let loadingInstance;
export default {
  // 消息提示
  msg(content) {
    Message.info(content)
  },
  // 错误消息
  msgError(content) {
    Message.error(content)
  },
  // 成功消息
  msgSuccess(content) {
    Message.success(content)
  },
  // 警告消息
  msgWarning(content) {
    Message.warning(content)
  },
  // 弹出提示
  alert(content) {
   return MessageBox.alert(content, "系统提示",{
      type: 'error',
      cancelButtonText: '取消',
      confirmButtonText: '确定',
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 错误提示
  alertError(content) {
   return MessageBox.alert(content, "系统提示", {
      type: 'error',
      cancelButtonText: '取消',
      confirmButtonText: '确定',
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 成功提示
  alertSuccess(content) {
   return MessageBox.alert(content, "系统提示", {
      type: 'success',
      type: 'warning',
       cancelButtonText: '取消',
      confirmButtonText: '确定',
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 警告提示
  alertWarning(content) {
   return MessageBox.alert(content, "系统提示", {
      type: 'warning',    
      confirmButtonText: '确定',
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 通知提示
  notify(content) {
    Notification.info(content)
  },
  // 错误通知
  notifyError(content) {
    Notification.error(content);
  },
  // 成功通知
  notifySuccess(content) {
    Notification.success(content)
  },
  // 警告通知
  notifyWarning(content) {
    Notification.warning(content)
  },
  // 确认窗体
  confirm(content) {
    return MessageBox.confirm(content, "系统提示", {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: "warning",
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 提交内容
  prompt(content) {
    return MessageBox.prompt(content, "系统提示", {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: "warning",
      confirmButtonClass: "searchButton",
      cancelButtonClass: "resetButton",
    })
  },
  // 打开遮罩层
  loading(content) {
    loadingInstance = Loading.service({
      lock: true,
      text: content,
      spinner: "el-icon-loading",
      background: "rgba(0, 0, 0, 0.7)",
    })
  },
  // 关闭遮罩层
  closeLoading() {
    loadingInstance.close();
  }
}
